<div class="modal fade" id="edit_back_reason" tabindex="-1">
    <div class="modal-dialog">
        <form id="edit_back_reason_form" name="edit_back_reason_form" method="post" action="/task/score/back">
            <input type="hidden" id="user_task_id" name="user_task_id" value=""/>
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="batch-title">
                        退回
                        </h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label>原因说明<span class="text-important">*</span></label>
                        <textarea id="back_reason" name="back_reason" class="form-control" type="text" style="height:120px"></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary" action-type="draft">确定</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $(".modal-body").delegate(".deletrow", "click", function () {
            var $this = $(this);
            var $row = $this.parent().parent().parent();
            $row.remove();
        });

        $('[data-toggle="modal"][data-target="#edit_back_reason"]').click(function () {
            reset_edit_task_form();
            var $this = $(this);
            var node = $this.parent().parent().parent();

            edit_edit_back_reason_form(node);
        });

        $("#edit_back_reason_form").validate({
            submitHandler: function () {
                $('#edit_back_reason_form button[action-type="draft"]').attr("disabled","true");
                $.post($("#edit_back_reason_form").attr("action"), $("#edit_back_reason_form").serialize(), function (data) {
                    if (data === "0") {
                        alertify.alert("操作成功!", function () {
                            $('#edit_back_reason_form').modal('hide');
                            location.reload();
                        });
                    } else {
                        alertify.alert(data);
                    }
                }).error(function (msg, url, line) {
                    alert(msg.responseText);
                });
            },
            ignore: "",
            rules: {
                back_reason: {
                    required: true
                }
            },
            messages: {
                back_reason: {
                    required: "请填写内容"
                }
            }
        });
    });

    function reset_edit_task_form() {
        $('#edit_back_reason_form input[name="user_task_id"]').val('');
    }

    function edit_edit_back_reason_form(node) {
        $('#edit_back_reason_form input[name="user_task_id"]').val(node.data('vid'));
    }

</script>